﻿<?xml version="1.0" encoding="utf-8" ?>

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly ="monitor_2_DBwork" namespace ="monitor_2_DBwork" >
  <class name="Devices" table="Devices" >
    <id name ="Id" column ="Id" type ="int" generator="identity"/>
    <!--<property name="Name" column="Name" type="string(45)" unique-key="key1"/>-->
    <property name="Iddevicelib" column="Iddevicelib" type="int"/>
    <property name="Idrtps" column="Idrtps" type="int"/>
    <property name="Title" column="Title" type="string"/>
    <property name="IPAddress" column="Ip" type="string(15)" unique="true"/>
    <property name="Active" column="Active" type="bool" not-null="true"/>

    <many-to-one name="Device" class="DevicesLibs" lazy="false" column="Iddevicelib"
                 cascade="all" insert="false" update="false" not-null="true"/>
    
    <many-to-one name="RTPS" class="RTPS" lazy="false" column="Idrtps"
                 cascade="all" insert="false" update="false" not-null="true"/>
    
    <!--cascade="all-delete-orphan"-->
    <set name="Logs" inverse="true" cascade="all-delete-orphan" order-by="Time desc">
      <key column="Devid" not-null="true" on-delete="cascade"/>
      <one-to-many class="DeviceLog"/>
    </set>
    
    <set name="IzmerStats" inverse="true" cascade="all-delete-orphan" order-by="Time desc">
      <key column="Iddevice" not-null="true" on-delete="cascade"/>
      <one-to-many class="IzmersStatistics"/>
    </set>
    
  </class>
</hibernate-mapping>